
#include "garbage.h"
#include "types.h"
#include "hashtable.h"
#include <AudioToolbox/AudioToolbox.h>

int sampling_rate;
double seconds;
counter samples;

int output_channels;
AudioUnitSampleType * output_samples;

/* public functions */

void process(counter cycles);
void startup();

module new_module(char * name);
void init(module m, char * name, char * value);

input * get_input(module m, char * name);
input * get_inputs(module m);
input * get_named_inputs(module m);
char ** get_input_names(module m);
int count_inputs(module m);
int count_named_inputs(module m);

output * get_output(module m, char * name);
output * get_outputs(module m);
output * get_named_outputs(module m);
char ** get_output_names(module m);
int count_outputs(module m);
int count_named_outputs(module m);

void patch(input * i, output * o);
void patches(input * i, output * o, int count);
void multiple(input * i, output * o, int count);

sample strtosample (char * s);
output * constant(sample v);
void patch_constant(input * i, sample v);
void patch_one(input * i);
void patch_zero(input * i);
void patches_constant(input * i, sample * v, int count);
void multiple_constant(input * i, sample v, int count);

void null_initializer(module m);
void null_processor(module m);
void null_customizer(module m, char * name, char * value);
void debug_modules(void);

void install_module(char * name, initializer i);

void customizer_count_inputs(module m, char * name, char * value);
void customizer_count_inputs_only(module m, char * name, char * value);
void customizer_buffer_seconds(module m, char * name, char * value);
void customizer_buffer_size(module m, char * name, char * value);
void customizer_output_buffer_size(module m, char * name, char * value);

void make_inputs(module m, int count);
void make_outputs(module m, int count);
void make_named_inputs(module m, int count, int named_count);
void make_named_outputs(module m, int count, int named_count);

void make_buffer(module m, int size);
void resize_buffer(module m, int size);

void safe_module(char * type, char * name);
void safe_init(char * mod, char * key, char * val);
void safe_patch(char * in_mod, char * in_stream, char * out_mod, char * out_stream);
void safe_patch_constant(char * in_mod, char * in_stream, char * val);
void safe_patch_all(char * in_mod, char * out_mod);

void safe_set_seconds(char * s);
void safe_set_samples(char * s);
void safe_set_sampling_rate(char * s);

